
package JET.graphics.elements;

import JET.geom.Vec2d;
import JET.graphics.GraphicPanel;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

/**
 *
 * @author 057Ry
 */
public class DrawableEllipse implements SceneDrawable {

    public double x=0,y=0,w=0,h=0;
    public Color color = Color.BLACK;
    public boolean filled = true;

    public DrawableEllipse(double x, double y, double w, double h) {
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
    }

    public DrawableEllipse(Vec2d p, double w, double h) {
        this.x = p.x;
        this.y = p.y;
        this.w = w;
        this.h = h;
    }

    public void setXY(Vec2d p) {
        x = p.x;
        y = p.y;
    }

    public void setXY(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public void draw(Graphics g, GraphicPanel gp) {
        double x = gp.engineToScrX( this.x );
        double y = gp.engineToScrY( this.y );
        double w = this.w*gp.getViewScale();
        double h = this.h*gp.getViewScale();

        Graphics2D g2d = (Graphics2D)g;
        g.setColor( color );
        if (filled)
            g2d.fill( new Ellipse2D.Double(x, y, w, h) );
        else
            g2d.draw( new Ellipse2D.Double(x, y, w, h) );
    }
}
